﻿$(function () {

    //延迟加载（懒加载）图片
    $("img.lazy").lazyload({
        effect: "fadeIn"
    });

    // 页数
    var page = 0;
    // 每页展示10个
    var size = 10;

    // dropload
    $('.content').dropload({
        scrollArea: window,
        domUp: {
            domClass: 'dropload-up',
            domRefresh: '<div class="dropload-refresh">↓下拉刷新</div>',
            domUpdate: '<div class="dropload-update">↑释放更新</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
        },
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">暂无数据</div>'
        },
        loadUpFn: function (me) {
            var result = '';
            for (var i = 0; i < 10; i++) {
                result += '<li class="aui-list-item">' +
                        '<a href="/Index/Content">' +
                         '<div class="aui-media-list-item-inner">' +
                           '<div class="aui-list-item-media"> <img data-original="/image/demo1.png" class="lazy" /> </div>' +
                           '<div class="aui-list-item-inner">' +
                           '<div class="aui-list-item-text">' +
                           '<div class="aui-list-item-title">山海天旅游度假区召开庆祝党建"七一"表彰大会向上滑动' + i + '</div>' +
                            '</div>' +
                            '<div class="aui-list-item-text"> 2016-12-01 </div>' +
                            '</div>' +
                            '</div>' +
                            '</a>' +
                            '</li>';

            }
            // 为了测试，延迟1秒加载
            setTimeout(function () {
                $('.lists ul').html(result);
                // 每次数据加载完，必须重置
                me.resetload();
                // 重置页数，重新获取loadDownFn的数据
                page = 0;
                // 解锁loadDownFn里锁定的情况
                me.unlock();
                me.noData(false);

                //延迟加载（懒加载）图片
                $("img.lazy").lazyload({
                    effect: "fadeIn"
                });

            }, 1000);
        },
        loadDownFn: function (me) {
            page++;
            // 拼接HTML
            var result = '';
            var arrLen = 3;
            if (arrLen > 0) {
                for (var i = 0; i < arrLen; i++) {
                    result += '<li class="aui-list-item">' +
                        '<a href="/Index/Content">' +
                         '<div class="aui-media-list-item-inner">' +
                           '<div class="aui-list-item-media"> <img data-original="/image/demo1.png" class="lazy" /> </div>' +
                           '<div class="aui-list-item-inner">' +
                           '<div class="aui-list-item-text">' +
                           '<div class="aui-list-item-title">山海天旅游度假区召开庆祝党建"七一"表彰大会向下滑动' + i + '</div>' +
                            '</div>' +
                            '<div class="aui-list-item-text"> 2016-12-01 </div>' +
                            '</div>' +
                            '</div>' +
                            '</a>' +
                            '</li>';
                }
                // 如果没有数据
            } else {
                // 锁定
                me.lock();
                // 无数据
                me.noData();
            }
            // 为了测试，延迟1秒加载
            setTimeout(function () {
                // 插入数据到页面，放到最后面
                $('.lists ul').append(result);
                // 每次数据插入，必须重置
                me.resetload();

                //延迟加载（懒加载）图片
                $("img.lazy").lazyload({
                    effect: "fadeIn"
                });

            }, 1000);
        },
        threshold: 50
    });
});

//轮播图效果
var slide3 = new auiSlide({
    container: document.getElementById("aui-slide3"),
    // "width":300,
    "height": 240,
    "speed": 500,
    "autoPlay": 3000, //自动播放
    "loop": true,
    "pageShow": true,
    "pageStyle": 'line',
    'dotPosition': 'center'
});